package com.rabbiter.oes.mapper;

import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.rabbiter.oes.entity.FillQuestion;
import com.rabbiter.oes.entity.JudgeQuestion;
import com.rabbiter.oes.entity.MultiQuestion;
import com.rabbiter.oes.vo.AnswerVO;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

@Mapper
public interface AnswerMapper {
    IPage<AnswerVO> findAll(Page<AnswerVO> page,
                            @Param("question") String question,
                            @Param("subject") String subject);


    /**
     * 查选择题
     * @param questionId 选择题id
     * @return 选择题
     */
    @Select("SELECT questionId, subject, question, answerA, answerB, answerC, answerD, rightAnswer, analysis " +
            "FROM multi_question WHERE questionId = #{questionId}")
    MultiQuestion findMultiQuestionById(Long questionId);

    /**
     * 查填空题
     * @param questionId 题目id
     * @return 填空题
     */
    @Select("SELECT questionId, subject, question, answer, analysis " +
            "FROM fill_question WHERE questionId = #{questionId}")
    FillQuestion findFillQuestionById(Long questionId);

    /**
     * 查判断题
     * @param questionId 题目id
     * @return 判断题
     */
    @Select("SELECT questionId, subject, question, answer, analysis " +
            "FROM judge_question WHERE questionId = #{questionId}")
    JudgeQuestion findJudgeQuestionById(Long questionId);
}